var SAVE;
var CLOSE;
var QUERY;
var CLOSE_QUERY;
var CLOSE_VIEW;

/**
 * 是否允许编辑
 * @param BOOL
 */
function EDITABLE(BOOL){
	if(BOOL){
		$("input").removeAttr("readonly");
	}else{
		$("input").attr("readonly", "readonly");
	}
}

/**
 * 初始化增改页面面板
 * @param PANELID		面板ID
 * @param BUSINESSNAME	业务名称
 */
function CU_PANEL_INIT(PANELID, BUSINESSNAME){
	
	
	var HTML = '<div id="' + BUSINESSNAME + '_CU_PANEL" class="borsty-b">'
		HTML += '<a id="' + BUSINESSNAME + 'SaveBtn" href="javascript:void(0);" class="easyui-linkbutton" onclick="SAVE();">保存</a> '
		HTML += '<a id="' + BUSINESSNAME + 'WindowCloseBtn" href="javascript:void(0);" class="easyui-linkbutton" onclick="CLOSE();">关闭</a>'
		HTML += '</div>';
		PANELID.html(HTML);
		
		PANEL_INIT(GETID(BUSINESSNAME + '_CU_PANEL'));

		$('#' + BUSINESSNAME + 'SaveBtn').linkbutton({plain:true,iconCls:'icon-save'});
		$('#' + BUSINESSNAME + 'WindowCloseBtn').linkbutton({plain:true,iconCls:'icon-close'});
}

/**
 * 设置CU窗口保存、关闭方法
 * @param SAVEFUNCTION	保存方法
 * @param CLOSEFUNCTION	关闭方法
 */
function SET_CU_FUNCTION(SAVEFUNCTION, CLOSEFUNCTION){
	SAVE = SAVEFUNCTION;
	CLOSE = CLOSEFUNCTION;
}

/**
 * 初始化浏览页面面板
 * @param PANELID
 * @param BUSINESSNAME
 */
function V_PANEL_INIT(PANELID, BUSINESSNAME){
	
	var HTML = '<div id="' + BUSINESSNAME + '_V_PANEL" class="borsty-b">'
	HTML += '<span id="' + BUSINESSNAME + 'WorkflowBtn"></span>'
	HTML += '<a id="' + BUSINESSNAME + 'ViewCloseBtn" href="javascript:void(0);" class="easyui-linkbutton" onclick="CLOSE_VIEW();">关闭</a>'
	HTML += '</div>';
	PANELID.html(HTML);
	
	PANEL_INIT(GETID(BUSINESSNAME + '_V_PANEL'));
	
	$('#' + BUSINESSNAME + 'ViewCloseBtn').linkbutton({plain:true,iconCls:'icon-close'});
}

/**
 * 设置浏览窗口关闭方法
 * @param CLOSEFUNCTION		关闭窗口方法
 */
function SET_V_FUNCTION(CLOSEFUNCTION){
	CLOSE_VIEW = CLOSEFUNCTION;
}

/**
 * 初始化查询页面面板
 * @param PANELID
 * @param BUSINESSNAME
 */
function QU_PANEL_INIT(PANELID, BUSINESSNAME){
	var HTML = '<div id="' + BUSINESSNAME + '_QU_PANEL" class="borsty-b">'
	HTML += '<a id="' + BUSINESSNAME + 'QueryBtn" href="javascript:void(0);" class="easyui-linkbutton" onclick="QUERY();">查询</a> '
	HTML += '<a id="' + BUSINESSNAME + 'QueryWindowCloseBtn" href="javascript:void(0);" class="easyui-linkbutton" onclick="CLOSE_QUERY();">关闭</a>'
	HTML += '</div>';
	PANELID.html(HTML);
	
	PANEL_INIT(GETID(BUSINESSNAME + '_QU_PANEL'));
	
	$('#' + BUSINESSNAME + 'QueryBtn').linkbutton({plain:true,iconCls:'icon-search'});
	$('#' + BUSINESSNAME + 'QueryWindowCloseBtn').linkbutton({plain:true,iconCls:'icon-close'});
}

/**
 * 设置QU窗口查询、关闭方法
 * @param QUERYFUNCTION		查询方法
 * @param QUCLOSEFUNCTION	关闭查询敞口
 */
function SET_QU_FUNCTION(QUERYFUNCTION, CLOSEFUNCTION){
	QUERY = QUERYFUNCTION;
	CLOSE_QUERY = CLOSEFUNCTION;
}

/**
 * 初始化浏览权限列表
 * @param AUTVIEWID		浏览权限组件ID
 * @param AUTVIEWNAME	浏览权限组件名称
 * @param WIDTH			宽度
 */
function QUERY_INIT(AUTVIEWID, WIDTH){
	//部门下拉菜单
	AUTVIEWID.combobox({
		width:WIDTH,
		url:'doAutAjax!doAutDepart?wid='+getCurTabID(),
		valueField:'id',
		textField:'text'
	});
	AUTVIEWID.combobox('select', 'view');
}

/**
 * 获取浏览权限值
 * @param AUTVIEWNAME	浏览权限组件名称
 * @returns	选择的值
 */
function GETAUTVIEW(AUTVIEWID){
	return AUTVIEWID.combobox('getValue');
}

//编辑权限
function AUT_EDIT(ROW, FUNCTION_EDIT){
	//alert(FUNCTION_EDIT);
	$.post('doAutAjax!doAutEdit', {wid: getCurTabID(), personId: ROW.personId, departId: ROW.departId},
			function(data){
				//alert(data);
				if(data.result=='false'){
					MESSAGEBOX('不允许编辑其它用户或部门的数据!');
				}else{
					FUNCTION_EDIT();
				}
			}, 'json');
	
}

//根据权限删除
function AUT_REMOVE(ROW, FUNCTION_REMOVE){
	//alert(FUNCTION_REMOVE);
	$.post('doAutAjax!doAutDel', {wid: getCurTabID(), personId: ROW.personId, departId: ROW.departId},
			function(data){		
				if(data.result=='false'){
					MESSAGEBOX('不允许删除其它用户或部门的数据!');
				}else{
					$.messager.confirm('提示', '确认要删除此数据吗?', function(r){
						if (r){
							FUNCTION_REMOVE();
						}
					});
				}
			}, 'json');
}

